__author__ = 'toriycn'
import subprocess
import sys
def monitor():
    shell_command = 'uptime'

    result = subprocess.check_output(shell_command,shell=True)
    result = str(result.decode("utf-8"))

    value_dic = {}
    uptime = result.split(',')[:1][0]

    if sys.platform.startswith('linux'):
       load1,load5,load15=result.split('load average:')[1].split(',')
    if sys.platform.startswith('darwin'):
       load1,load5,load15=result.split('load averages:')[1].strip().split(' ')

    value_dic = {
        'uptime' : uptime,
        'load1' : load1,
        'load5':load5,
        'load15':load15,
        'status':0
    }
    return value_dic

if __name__ == '__main__':
    print(monitor())

